﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;

using ARNative;

namespace NRemedy.MVC.UI
{
    public class MenuObject
    {
        public String TargetForm { get; set; }

        public uint TargetValueFieldId { get; set; }

        public uint TargetTextFieldId { get; set; }

        public ARSortInfo TargetSortField { get; set; }

        /// <summary>
        /// '536784567' = $310000000$
        /// </summary>
        public String Qualification { get; set; }

        public List<string> Impacts { get; set; }

        //get url format from current menuobject
        //Menu/Query/{form}/{vid}/{tid}?sid=&sd=&qu=
        public virtual string GetMenuUrl(){
            string baseUrl = "/Menu/Query/" + TargetForm + "/" + TargetValueFieldId.ToString() + "/" + TargetTextFieldId.ToString();
            if (TargetSortField != null){
                baseUrl += "?sid=" + TargetSortField.FieldId.ToString();
                baseUrl += "&sd=" + (TargetSortField.Order == SortOrder.SORT_DESCENDING ? "desc" : "asc");
            }
            return baseUrl;
        }


        public virtual IEnumerable<String> GetImpacts()
        {
            if (Impacts != null)
                return Impacts.ToArray();
            else
                return null;
        }


    }

}
